package org.yray.sip.handler.flow;


import lombok.extern.slf4j.Slf4j;
import org.yray.sip.base.MsgType;
import org.yray.sip.base.SipMsg;
import org.yray.sip.creator.MessageCreator;
import org.yray.sip.handler.MessageHandler;
import org.yray.sip.server.SipServerContext;
import org.yray.sip.server.SipSession;
import org.yray.sip.visit.ISipAccept;
import org.yray.sip.visit.SipVisitorFactory;


@Slf4j
public class OK_InviteHandler extends MessageHandler {

    public static final OK_InviteHandler instance=new OK_InviteHandler();



    @Override
    public String[] handler(SipMsg sipMsg, SipServerContext ssc) {
        String callId= sipMsg.getCallId();
        ISipAccept sipAccept=getSipVisitorFactory().getSipAccept(callId);
        sipAccept.accept(SipVisitorFactory.SIP_200_VISITOR,sipMsg,ssc);
        SipSession sipSession= new SipSession(sipMsg,ssc.getRunIp(),ssc.getRunPort(),false);
        String result= MessageCreator.getCreator(MsgType.ACK).createMsg(sipSession);
        return new String[]{result};
    }
}
